package com.lg.spring.config;

import com.lg.spring.servlet.MyServlet2;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author by Mr. Li 2020/9/16 15:31
 */
@Configuration
public class MyServletRegistrationConfig {
	/**
	 * 使用Spring 提供的一种专门注册Servlet 的Bean
	 *
	 * @return
	 */
	@Bean
	public ServletRegistrationBean myServletRegistrationBean() {
		ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean();

		servletRegistrationBean.addUrlMappings("/myServlet2");
		servletRegistrationBean.setServlet(new MyServlet2());

		return servletRegistrationBean;
	}
}
